package com.woniuxy.microretailserver.mapper;

import com.woniuxy.microretailserver.bean.GoodsOrderBean;
import com.woniuxy.microretailserver.bean.GoodsReturnInfoBean;
import com.woniuxy.microretailserver.bean.PageRequest;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author chenhu
 * 退货订单持久层接口
 */
@Mapper
public interface GoodsReturnInfoMapper {

    /**
     * 新增退货订单信息
     *
     * @param goodsReturnInfoBean
     * @return
     */
    @Options(useGeneratedKeys = true, keyProperty = "g.id")
    @Insert("insert into t_goods_return_info" +
            "(order_no,goods_count,order_money,store,terminal,user_name,create_time,reduction)" +
            " values(#{g.orderNo},#{g.goodsCount},#{g.orderMoney},#{g.store},#{g.terminal},#{g.userName},now(),#{g.reduction})")
    int saveGoodsReturnInfo(@Param("g") GoodsReturnInfoBean goodsReturnInfoBean);

    /**
     * 分页查询商品退货订单信息
     * @param request
     * @param goodsReturnInfoBean
     * @return
     */
    List<GoodsReturnInfoBean> findAllGoodsReturn(@Param("p") PageRequest request, @Param("g") GoodsReturnInfoBean goodsReturnInfoBean);

    /**
     * 根据订单号查询订单退货信息
     * @param orderNo
     * @return
     */
    @Select("select id,order_no,create_time,order_money,store,terminal,goods_count,user_name,reduction from t_goods_return_info where order_no=#{orderNo}")
    GoodsReturnInfoBean findByReturnOrderNo(@Param("orderNo") String orderNo);

    /**
     * 导出退货订单数据
     * @return
     */
    @Select("select * from t_goods_return_info")
    List<GoodsReturnInfoBean> findByAllReturn();
}
